package com.ym.controller.medical;

import com.ym.core.annotation.Log;
import com.ym.core.domain.APIResponse;
import com.ym.core.domain.BaseController;
import com.ym.medical.domain.entity.JpushAccountEntity;
import com.ym.medical.service.IJpushAccountSV;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * 极光账号Controller
 *
 * @author ym
 * @date 2020-08-21
 */
@Api(tags = "medical-极光账号")
@RestController
@Validated
@RequestMapping("/medical/account")
public class JpushAccountController extends BaseController {

	@Autowired
	private IJpushAccountSV jpushAccountSV;

	@ApiOperation("获取极光账号详细信息")
	@Log(dataBase = false, printBody = false, printQuery = true)
	@GetMapping(value = "/info")
	public APIResponse<JpushAccountEntity> info(@RequestParam Long id) {
		JpushAccountEntity data = jpushAccountSV.selectById(id);
		return successData(data);
	}

	@ApiOperation("删除极光账号")
	@Log(printQuery = false)
	@PostMapping("/delete")
	public APIResponse delete(@RequestBody @Valid @NotNull Long[] ids) {
		int result = jpushAccountSV.deleteByIds(ids);
		return successData(result);
	}
}
